package com.ruizhong.PIW.controller;

import com.ruizhong.PIW.entity.TStyle;
import com.ruizhong.PIW.entity.TWindow;
import com.ruizhong.PIW.service.StyleService;
import com.ruizhong.PIW.utils.Result;
import com.ruizhong.PIW.utils.ResultCode;
import com.ruizhong.PIW.vo.StyleVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/style")
@CrossOrigin
@Slf4j
public class StyleController {

    @Autowired
    private StyleService styleService;

    @GetMapping("/getStyleList")
    public Result getStyleList() {
        List<TStyle> list = styleService.list();
        return new Result<>(ResultCode.success, null, list);
    }

    @GetMapping("/getStyleInfo/{styleId}")
    public Result getStyleInfo(@PathVariable Integer styleId) {
        StyleVO styleVO = styleService.getStyleInfo(styleId);
        return new Result<>(ResultCode.success, null, styleVO);
    }

    @GetMapping("/getAllStyleId")
    public Result getAllStyleId() {
        List<Integer> styles = styleService.getAllStyleId();
        return new Result(ResultCode.success, null, styles);
    }
}
